<?php
/**
 * Author: Hancock
 * Email: 84622365@qq.com
 * Date: 7/18/2016
 * Des: 系统管理员
 */
defined('INHkMvc') or exit('Access Invalid!');

class App_app_versionModel extends AppModel
{
    /**
     * 获取当前版本
     * @param  string  $current_version [description]
     * @param  integer $system          [description]
     * @return [type]                   [description]
     */
    public function getCurrentVersion($current_version,$system,$fields=''){

        $where=['system'=>$system,'version'=>$current_version];
        $res=$this->field('id')->find($where);
            
        $where=['system'=>$system,'force'=>'1','id'=>array('gt',$res['id'])];
        $version=$this->field('id')->select($where);
        $force=$version?1:0;
        $where=array('system'=>$system);
        $max_version=$this->field($fields)->order('id desc')->find($where);
        $max_version['force']=$force;
        return $max_version;
    }
}
